﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Util._3DWall.Wall;
using Util.Layout.Test.Entities;

namespace Util.Layout.Test.Views
{
    /// <summary>
    /// _3DWallView.xaml 的交互逻辑
    /// </summary>
    public partial class _3DWallView : UserControl
    {
        public _3DWallView()
        {
            InitializeComponent();
            Loaded += _3DWallView_Loaded;
        }


        void _3DWallView_Loaded(object sender, RoutedEventArgs e)
        {
            Loaded -= _3DWallView_Loaded;

            _mainwall.ItemClick += _mainwall_ItemClick;
        }

        Popwindow Picture;
        void _mainwall_ItemClick(object sender, _3DWall.Wall.WallControl.ItemclickEventArg e)
        {
            Picture = new Popwindow();
            Picture.HorizontalAlignment = HorizontalAlignment.Center;
            Picture.VerticalAlignment = VerticalAlignment.Center;

            Image image = new Image();
            image.Source = new BitmapImage(new Uri((e.Data as WallItemData).Source));
            Picture.Content = image;
       
            _grid.Children.Add(Picture);
            _rec.Visibility = Visibility.Visible;
            _rec.MouseLeftButtonDown += _rec_MouseLeftButtonDown;

        }

        void _rec_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _rec.Visibility = Visibility.Collapsed;
            _rec.MouseLeftButtonDown -= _rec_MouseLeftButtonDown;
            _grid.Children.Remove(Picture);
        }
    }
}
